{
LANG : PASCAL
PROB : beads
}

program BEADS;
const
  fi = 'beads.in';
  fo = 'beads.out';
  max = 350;
var
  a : array[0..2*max+1] of char;
  lb, lr, rb, rr : array[0..2*max+1] of integer;
  n, maximum : integer;

procedure inp;
var
  i : integer;
begin
  readln(n);
  for i := 1 to n do read(a[i]);
  move(a[1], a[n+1], n);
end;

procedure init;
var
  i, j : integer;
begin
  lb[0] := 0;
  for i := 1 to 2*n do
    if a[i] = 'r' then lb[i] := 0
    else lb[i] := lb[i-1]+1;
  move(lb[n+1], lb[1], sizeof(lb[1])*n);

  lr[0] := 0;
  for i := 1 to 2*n do
    if a[i] = 'b' then lr[i] := 0
    else lr[i] := lr[i-1] + 1;
  move(lr[n+1], lr[1], sizeof(lr[1])*n);

  rb[2*n+1] := 0;
  for i := 2*n downto 1 do
    if a[i] = 'r' then rb[i] := 0
    else rb[i] := rb[i+1] + 1;

  rr[2*n+1] := 0;
  for i := 2*n downto 1 do
    if a[i] = 'b' then rr[i] := 0
    else rr[i] := rr[i+1] + 1;
end;

procedure process;
var
  v : integer;
begin
  maximum := 0;
  for v := 1 to n+1 do
  begin
    if maximum < lb[v] + rr[v+1] then maximum := lb[v] + rr[v+1];
    if maximum < lr[v] + rb[v+1] then maximum := lr[v] + rb[v+1];
  end;
  if maximum > n then maximum := n;
end;

begin
  assign(input, fi); reset(input);
  assign(output, fo); rewrite(output);
  inp;
  init;
  process;
  writeln(maximum);
  close(output);
  close(input);
end.